package com.edgclub.edg.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.edgclub.edg.R;
import com.edgclub.edg.uc.MenuPopWindow;

import java.util.ArrayList;

public class MenuPopAdapter extends BaseAdapter {


	public Context context;

	private ArrayList<MenuData> menuDatas;

	public MenuPopAdapter(Context context , ArrayList<MenuData> menuDatas) {
		this.context = context;
		this.menuDatas = menuDatas;
	}

	@Override
	public int getCount() {
		return menuDatas.size();
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup group) {
		ViewHolder holder;
		if (null == convertView) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.item_menu_pop, null);

			holder = new ViewHolder();
			holder.icon = (ImageView) convertView.findViewById(R.id.menu_icon);
			holder.text = (TextView) convertView.findViewById(R.id.menu_name);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		MenuData data = menuDatas.get(position);
		holder.icon.setImageResource(data.icon);
		holder.text.setText(data.name);
		if (data.tag.equals(MenuPopWindow.tag_delete) || data.tag.equals(MenuPopWindow.tag_remove_channel)){
			holder.text.setTextColor(context.getResources().getColor(R.color.c1));
		} else {
			holder.text.setTextColor(context.getResources().getColor(R.color.c10));

		}
		return convertView;
	}

	class ViewHolder {
		public ImageView icon;
		public TextView text;
	}

	public  static  class MenuData{
		public int icon;
		public String name;
		public String tag;

		public MenuData(int icon, String name, String tag) {
			this.icon = icon;
			this.name = name;
			this.tag = tag;
		}
	}

	public ArrayList<MenuData> getMenuDatas() {
		return menuDatas;
	}

	public void setMenuDatas(ArrayList<MenuData> menuDatas) {
		this.menuDatas = menuDatas;
	}
}
